-
Notifications
You must be signed in to change notification settings - Fork 120
/
HitWithInsights.js
45 lines (42 loc) · 1.13 KB
/
HitWithInsights.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { connectHitInsights, Highlight } from 'react-instantsearch-dom';
import PropTypes from 'prop-types';
import React from 'react';
function Hit({ hit, insights }) {
return (
<div>
<img src={hit.image} align="left" alt={hit.name} />
<div className="hit-name">
<Highlight attribute="name" hit={hit} />
</div>
<div className="hit-description">
<Highlight attribute="description" hit={hit} />
</div>
<div className="hit-price">${hit.price}</div>
<button
className="hit-action"
onClick={() => {
insights('clickedObjectIDsAfterSearch', {
eventName: 'Add to favorite',
});
}}
>
Send click
</button>
<button
className="hit-action"
onClick={() => {
insights('convertedObjectIDsAfterSearch', {
eventName: 'Add to basket',
});
}}
>
Send conversion
</button>
</div>
);
}
Hit.propTypes = {
hit: PropTypes.object.isRequired,
insights: PropTypes.func.isRequired,
};
export const HitWithInsights = connectHitInsights(window.aa)(Hit);